package com.liguangting.agentsflex.simple;

import com.agentsflex.core.llm.ChatContext;
import com.agentsflex.core.llm.Llm;
import com.agentsflex.core.llm.StreamResponseListener;
import com.agentsflex.core.llm.response.AiMessageResponse;
import com.agentsflex.llm.openai.OpenAiLlm;
import com.liguangting.agentsflex.constant.ApiKeys;


/**
 * @author liguangting
 * @date 2024/7/2
 * @description
 */
public class OpenAiLlmTest {

    public static void main(String[] args) {
        Llm llm = OpenAiLlm.of(ApiKeys.OPENAI_API_KEY);
//        String response = llm.chat("杭州有什么好玩的地方?");
//        System.out.println(response);

        llm.chatStream("1+1=?", new StreamResponseListener<AiMessageResponse>() {

            @Override
            public void onMessage(ChatContext context, AiMessageResponse response) {
                System.out.print(response.getMessage().getContent());
            }
        });
    }
}
